package com.xphu.service;

import com.xphu.resolve.JDOrderResolve;
import com.xphu.resolve.SFOrderResolve;
import com.xphu.resolve.YTOrderResolve;
import com.xphu.strategy.OrderStrategy;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author xphu
 * @version 1.0
 * @date 2021/11/5 12:19
 */
public class OrderService {
    private Map<String, OrderStrategy> orderStrategyMap = new ConcurrentHashMap<String, OrderStrategy>();

    public void distribute(String type, int orderId){
        OrderStrategy strategy = orderStrategyMap.get(type);
        if (strategy!=null){
            strategy.deliverOrder(orderId);
        }
    }

    public OrderService() {
        orderStrategyMap.put("京东", new JDOrderResolve());
        orderStrategyMap.put("顺风", new SFOrderResolve());
        orderStrategyMap.put("圆通", new YTOrderResolve());
    }
}
